﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TruthTree2.PC.Logic
{
    public class Disjunction : Sentence
    {
        public override int SortValue { get { return 2; } }
        public override bool Decomposable { get { return true; } }

        internal Sentence left, right;

        public Disjunction(Sentence l, Sentence r)
        {
            left = l;
            right = r;
        }

        public override Sentence Copy()
        {
            return new Disjunction(left.Copy(), right.Copy());
        }

        public override Decomposition GetDecomposition()
        {
            Decomposition decomp = new Decomposition();
            decomp.AddToLeft(left.Copy());
            decomp.AddToRight(right.Copy());

            return decomp;
        }

        public override bool Equal(Sentence o)
        {
            if (o is Disjunction)
            {
                Disjunction d = (Disjunction)o;
                return (left.Equal(d.left) && right.Equal(d.right)) ||
                       (left.Equal(d.right) && right.Equal(d.left));
            }

            return false;
        }

        public override string ToString()
        {
            return "(or " + left.ToString() + " " + right.ToString() + ")";
        }
    }
}
